﻿Public Class FrmCursos
    Dim Descripcion(4) As String
    Private Sub FrmCursos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        lblAnyo.Text = CType(Year(Today), String)
        Descripcion(0) = "Conocer los conceptos basicos"
    End Sub


    Private Sub lstCursos_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstCursos.SelectedIndexChanged
        btnSeleccionar.Enabled = True

    End Sub

    Private Sub btnSeleccionar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSeleccionar.Click
        txtCiclo.Focus()
        txtDescripcion.Text = Descripcion(lstCursos.SelectedIndex)
        PnlDatos.Enabled = True
        btnAgregar.Enabled = True
        btnSeleccionar.Enabled = False

    End Sub

    Private Sub btnAgregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAgregar.Click
        registros_Ciclos += 1
        ReDim Preserve arreglo_ciclo(4, registros_Ciclos)

        Dim Indice As Integer
        Dim valor_Encontrado As Boolean = False
        For Indice = 0 To arreglo_ciclo.GetLength(1) - 1
            If Trim(arreglo_ciclo(0, Indice)) = Trim(lblAnyo.Text + txtCiclo.Text) _
                And Trim(arreglo_ciclo(1, Indice)) = Trim(lstCursos.SelectedItem) Then
                valor_Encontrado = True
            End If
        Next
        'ciclo existe
        If valor_Encontrado Then
            MessageBox.Show("Ciclo ya registrado...", "Error...", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Exit Sub
        End If
        'Asignar los datos a cada elemento del arreglo
    End Sub
End Class